﻿package cn.poco.pepsi.service.impl;

import java.io.InputStream;
import java.util.ArrayList;

import android.util.Log;
import cn.poco.pepsi.bean.FoodPhoto;
import cn.poco.pepsi.bean.Guest;
import cn.poco.pepsi.service.IPhoto;
import cn.poco.pepsi.util.UrlConnectionUtil;
import cn.poco.pepsi.util.UrlMatchUtil;
import cn.poco.pepsi.util.xmlpared.GuestXmlparse;
import cn.poco.pepsi.util.xmlpared.PhotoXmlparse;


public class PhotoImpl implements IPhoto {

	@Override
	public ArrayList<FoodPhoto> getHotPhoto(int type, int resid,int s, int l) {
		//resid=#res&s=#a&l=#b
		String url= IPhoto.PATHHot;
		url=url.replace("#resid",String.valueOf(resid)).replace("#a", String.valueOf(s)).replace("#b", String.valueOf(l));
		InputStream inSteam;
		ArrayList<FoodPhoto> list =new ArrayList<FoodPhoto>();
		try {
			//url=UrlMatchUtil.matchUrl(url);
			Log.i("impl餐厅美图", url);
			inSteam = UrlConnectionUtil.getRequest(url);
			list=PhotoXmlparse.getXml(inSteam);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return list;
	}

	@Override
	public ArrayList<Guest> getNewPhoto(int s, int l) {
		String url= IPhoto.PATHNew;
		url=url.replace("#a", String.valueOf(s)).replace("#b", String.valueOf(l));
		InputStream inSteam;
		ArrayList<Guest> list =new ArrayList<Guest>();
		try {
			url=UrlMatchUtil.matchUrl(url);
			Log.i("impl", url);
			inSteam = UrlConnectionUtil.getRequest(url);
			list=GuestXmlparse.getXml(inSteam);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return list;
	}

}
